package com.example.springbootdemo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.data.redis.core.StringRedisTemplate;

@RestController
@RequestMapping("/redis")

public class RedisTestController{
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @GetMapping("/set")
    public String setValue(@RequestParam String key, @RequestParam String value){
        stringRedisTemplate.opsForValue().set(key,value);
        return "set success";
    }

    @GetMapping("/get")
    public String getValue(@RequestParam String key){
        return stringRedisTemplate.opsForValue().get(key);
    }
}